#pragma once
#include "EventLoop.h"
#include "Socket.h"
#include "Channel.h"
#include "Acceptor.h"
#include <map>
class TcpServer {
private:
    EventLoop loop_;  // 单线程下暂时只用一个事件循环
    Acceptor *acceptor_; // 一个TcpServer只有一个Acceptor对象
    std::map<int,Connection*> conns_;
public:
    TcpServer(const std::string &ip, const uint16_t port);
    ~TcpServer();

    void start();

    void newconnection(Socket* clientsock);
    void closeconnection(Connection *conn);
    void errorconnection(Connection *conn);
};